
import org.freeswitch.*;
import org.freeswitch.swig.*;

public class PhoneTest implements FreeswitchScript, DTMFCallback, HangupHook
{
	
    public PhoneTest()
    {
    }

    public String onDTMF(Object object, int i, String arg)
    {
        if (object instanceof String)
        	
            freeswitch.console_log("notice", "DTMF: " + (String)object + " ARG: " + arg + "\n");
        else
            freeswitch.console_log("notice", "WOW GOT AN EVENT: " + object.toString());
        return "true";
    }

    public void onHangup()
    {
        freeswitch.console_log("notice", "HANGUP!\n");
    }
//User Defined Functions

//*********************
    public void run(String sessionUuid, String args)
    {
        freeswitch.console_log("notice", "UUID: " + sessionUuid + " ARGS: " + args + "\n");
        JavaSession session = null;
        try
            {
                session = new JavaSession(sessionUuid);
                session.setDTMFCallback(this, "TEST");
                session.setHangupHook(this);
                

                session.answer();
                int i=0;
                while(i<1)
                {
                session.streamFile(args, 0);
                }
                session.hangup("");
            }
        finally
            {
                if (session != null)
                    session.delete();
            }
    }
}